package com.example.user_service.config;

import io.swagger.annotations.SwaggerDefinition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author XiaoLiu
 * @date 2021-12-08 15:33
 **/
@Configuration
@EnableSwagger2
public class SwaagerConfig
{
    @Bean
    public Docket getSwagger()
    {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(getApI())
                .select()
                .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
                .paths(PathSelectors.any())
                .build();

    }
    private ApiInfo getApI()
    {
        //通过APIBuilder构建ApiInfo
        return new ApiInfoBuilder()
                //指定标题
                .title("user_service服务接口文档")
                //指定描述信息
                .description("用户信息")
                //指定版本信息
                .version("v1.0.0")
                //指定联系人信息
                .contact(new Contact("lhj","www.sunjob.com","1575266103@qq.com"))
                .build();
    }
}
